﻿Public Class formcopydir

    Private Sub copydir_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        checkcstring.Checked = True
        lbncustominfo.Enabled = False


    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnroot.Click
        If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
            ' List files in the folder.
            textcopyroot.Text = (FolderBrowserDialog1.SelectedPath)
        End If




    End Sub

    Private Sub checkcstring_CheckedChanged(sender As Object, e As EventArgs) Handles checkcstring.CheckedChanged
        If checkcstring.Checked = True Then
            textcopydest.Enabled = False
            checkpath.Checked = False


        Else
            textcopydest.Enabled = True




        End If
    End Sub

    Private Sub checkpath_CheckedChanged(sender As Object, e As EventArgs) Handles checkpath.CheckedChanged
        If checkcstring.Checked = True Then
            checkcstring.Checked = False
            textcopydest.Enabled = True
            lbncustominfo.Enabled = True

        End If
    End Sub

    Private Sub btndest_Click(sender As Object, e As EventArgs)
       

        If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
            ' List files in the folder.
            textcopydest.Text = (FolderBrowserDialog1.SelectedPath)
        
        End If
    End Sub

    Private Sub btncopyrun_Click(sender As Object, e As EventArgs) Handles btncopyrun.Click

        ' Dim fileReader As String

        'fileReader = textipremote.Text

        If Not textcopyroot.Text = (FolderBrowserDialog1.SelectedPath) Then
            MsgBox("Please define directory", MsgBoxStyle.Exclamation)
            Return
        End If

        ' If textipremote.Text = "" Then
        'MsgBox("Please define Ip remote", MsgBoxStyle.Exclamation)
        'Return
        'End If

        If checkcstring.Checked = True Then

            labelprogress.Text = "Coping files...."

            For Each ReadLine As String In textipremote.Text

            Next

            ' My.Computer.FileSystem.CopyFile(item, SaveArea.SelectedPath & "\" & IO.Path.GetFileName(item))

            My.Computer.FileSystem.CopyDirectory(textcopyroot.Text, "\\" + textipremote.Text + "\c$\", True)


            labelprogress.Text = " Finish...."

            textipremote.Clear()
            textcopyroot.Clear()
            textcopydest.Clear()

        ElseIf checkpath.Checked = True Then

            labelprogress.Text = "Coping files...."

            My.Computer.FileSystem.CopyDirectory(textcopyroot.Text, "\\" + textipremote.Text + "\c$" + textcopydest.Text, showUI:=FileIO.UIOption.AllDialogs, onUserCancel:=FileIO.UICancelOption.DoNothing)
            labelprogress.Text = " Finish...."
            textipremote.Clear()
            textcopyroot.Clear()
            textcopydest.Clear()
        Else
            MsgBox("Please define c$ o path custom ", MsgBoxStyle.Exclamation)
        End If




    End Sub

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Close()

    End Sub

    Private Sub textcopyroot_TextChanged(sender As Object, e As EventArgs) Handles textcopyroot.TextChanged

    End Sub

    Private Sub ProgressBar1_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub textipremote_TextChanged(sender As Object, e As EventArgs) Handles textipremote.TextChanged

    End Sub

    Private Sub select_host_Click(sender As Object, e As EventArgs) Handles select_host.Click
        Dim fileReader2 As String
        fileReader2 = My.Computer.FileSystem.ReadAllText("C:\testip.csv")
        textipremote.Text = fileReader2

       




        '    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        '       Dim reader As New System.IO.StreamReader("C:\text.txt")
        '      Dim allLines As List(Of String) = New List(Of String)
        '     Do While Not reader.EndOfStream
        'allLines.Add(reader.ReadLine())
        'Loop
        'reader.Close()
        'txtFirstName.Text = ReadLine(5, allLines)
        'txtLastName.Text = ReadLine(6, allLines)

    End Sub

    Public Function ReadLine(lineNumber As Integer, lines As List(Of String)) As String
        Return lines(lineNumber - 1)
    End Function
       
 


End Class